<?php
/**
 * Created by PhpStorm.
 * User: Dinh Thi
 * Date: 11/11/14
 * Time: 8:58 PM
 */

namespace DinhThi\MVC;


class Properties {
    private $properties = array();
    private static $instance = null;
    private function __construct(){
    }

    /**
     * @return Properties
     */
    public static function getInstance(){
        if (Properties::$instance == null){
            Properties::$instance = new Properties();
        }
        return Properties::$instance;
    }

    /**
     * Load properties from configuration file
     * @param $filename string
     */
    public function load($filename){
        $this->properties = parse_ini_file($filename, true);
        Properties::$instance = $this;
    }


    /**
     * Get property by name
     * @param $name
     * @return mixed
     */
    public function getProperty($name){
        if (isset ($this->properties[$name]))
            return $this->properties[$name];
        return null;
    }

    /**
     * Set the value for $name property
     * @param $name
     * @param $value
     */
    public function setProperty($name, $value){
        $this->properties[$name] = $value;
    }

} 